home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-09-02 | 4.2 KB | 120 lines | [TEXT/CCL2] |
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;
- ;;; pict-scrolling-windows.lisp
- ;;;
- ;;; The class pict-scroller is a scroller view that caches its image in
- ;;; a pict.
- ;;;
- ;;; The class pict-scrolling-window is a scrolling window that uses a
- ;;; pict-scroller.
-
- (in-package :ccl)
-
- (require :pict-views)
- (require :scrollers-patch)
- (require :pict-scrap)
-
- (export '(pict-scrolling-window pict-scroller scroller scroller-class)
- 'ccl)
-
- (defclass pict-scroller (pict-view scroller) ())
-
- (defmethod set-pict-cache ((view pict-scroller) pict)
- (declare (ignore pict))
- (call-next-method) ; install the pict
- (update-scroll-bars view :length t)) ; inform scroller of field size
-
-
- (defclass pict-scrolling-window (window)
- ((scroller :accessor scroller)
- (scroller-class :allocation :class
- :reader scroller-class
- :initform 'pict-scroller)))
-
- (defmethod initialize-instance ((self pict-scrolling-window) &key
- (scroller-class (scroller-class self))
- (scroll-bar-class 'scroll-bar-dialog-item)
- h-scroll-class v-scroll-class track-thumb-p field-size)
- (call-next-method)
- (setf (scroller self) (make-instance
- scroller-class
- :view-container self
- :view-size (subtract-points (view-size self) #@(15 15))
- :view-position #@(0 0)
- :draw-scroller-outline nil
- :scroll-bar-class scroll-bar-class
- :h-scroll-class h-scroll-class
- :v-scroll-class v-scroll-class
- :track-thumb-p track-thumb-p
- :field-size field-size)))
-
-
- (defmethod set-view-size ((self pict-scrolling-window) h &optional v)
- (declare (ignore h v))
- (without-interrupts
- (call-next-method)
- (let* ((new-size (subtract-points (view-size self) #@(15 15))))
- (set-view-size (scroller self) new-size))))
-
- (defmethod window-zoom-event-handler ((self pict-scrolling-window) message)
- (declare (ignore message))
- (let ((size (field-size (scroller self))))
- (when size
- (let ((h (+ 15 (point-h size)))
- (v (+ 15 (point-v size))))
- (set-window-zoom-size self (make-point (min h (- *screen-width* 10))
- (min v (- *screen-height* *menubar-bottom* 10)))))))
- (without-interrupts
- (call-next-method)
- (let* ((new-size (subtract-points (view-size self) #@(15 15))))
- (set-view-size (scroller self) new-size))))
-
- (defmethod window-close ((self pict-scrolling-window))
- (call-next-method)
- (view-close (scroller self)))
-
- ;;; These methods interface with pict-scrap.
-
- (defmethod copy ((self pict-scrolling-window))
- (let ((pict (view-pict (scroller self))))
- (when pict
- (with-focused-view (scroller self)
- (without-interrupts
- (let ((topleft (rref pict Picture.picFrame.topleft))
- (bottomright (rref pict Picture.picFrame.bottomright)))
- (rlet ((frame :rect :topleft topleft :bottomright bottomright))
- (#_ClipRect frame)
- (let ((pict-copy (#_OpenPicture frame)))
- (#_DrawPicture pict frame)
- (#_ClosePicture)
- (put-scrap :pict pict-copy t)))))))))
-
- #|
- (defmethod paste ((self pict-scrolling-window))
- (let ((pict (get-scrap :pict)))
- (when pict
- (set-pict-cache (scroller self) pict))))
- |#
-
- (provide :pict-scrolling-windows)
-
- #|
-
- (defparameter w (make-instance 'pict-scrolling-window
- :window-type :document-with-zoom
- :track-thumb-p t))
-
- (let ((self (scroller w)))
- (with-pict-view (self 300 300)
- (set-fore-color w *red-color*)
- (paint-oval self 125 125 250 250)
- (set-fore-color w *blue-color*)
- (frame-rect self 70 70 150 150)
- (erase-oval self 100 100 185 185)
- (move-to self 250 150)
- (set-fore-color w *yellow-color*)
- (dotimes (i 50)
- (line-to self
- (round (+ 150 (* 100 (cos i))))
- (round (+ 150 (* 100 (sin i))))))))
- |#